<?
	require_once("inc_security.php");
	                    
	//khoi tao object Datagird
	$list = new fsDataGird($id_field, $name_field, translate_text("Listing"));
	$form = new form();
	$list->add("title","Thông tin banner","string",0,0);
	$list->add("title","Hiển thị banner","string",0,0);
	$list->add("adv_order","Thứ tự","int",1,0);
	$list->add("title","Active","int",0,0);
	
	$list->add("",translate_text("Copy"),"copy");
	$list->add("",translate_text("Edit"),"edit");
	$list->add("",translate_text("Delete"),"delete");
	
	$list->ajaxedit("forums_category");
	$sql =	$list->sqlSearch() . $list->searchKeyword($name_field . ",adv_link");
	 
	$total			= new db_count("SELECT 	count(*) AS count 
											 FROM 	".$fs_table."
											 WHERE 	1 " . $list->sqlSearch());

	$db_listing 	= new db_query("SELECT * 
									 FROM ".$fs_table."
									 WHERE 1 " . $list->sqlSearch() . "
									 ORDER BY " . $list->sqlSort() . $id_field ." DESC
									 " . $list->limit($total->total));
	$total_row = mysql_num_rows($db_listing->result);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
<?=$list->headerScript()?>
<script language="javascript" src="../../resource/js/swfObject.js"></script>
</head>
<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<? /*---------Body------------*/ ?>
<div id="listing">
  <?=$list->showHeader($total_row)?>
	<?
	$i=0; 
	while($row = mysql_fetch_assoc($db_listing->result)){
	$i++;
	?>
  		<?=$list->start_tr($i, $row["adv_id"]);?>
		<td>
			<?
			$form = new form();
			$form->create_table();
			$adv_startdate		= getValue("adv_startdate", "str", "POST", date("d/m/Y", $row["adv_start"]));
			$adv_starttime		= getValue("adv_starttime", "str", "POST", date("H:i:s", $row["adv_start"]));
			
			$adv_enddate		= getValue("adv_enddate", "str", "POST", date("d/m/Y", $row["adv_end"]));
			$adv_endtime		= getValue("adv_endtime", "str", "POST", date("H:i:s", $row["adv_end"]));			
			?>
			<tr>
				<td class="form_name">Vị trí : </td>
				<td class="form_text">
					<select class="form_control" name="adv_position_<?=$row["adv_id"]?>" id="adv_position_<?=$row["adv_id"]?>" onchange="check_edit('record_<?=$i?>')">
						<option value=""><?=translate_text("Chọn vị trí")?></option>
						<?
						foreach($array_position as $value => $arr){
							?><option value="<?=$value?>" <?=($row["adv_position"] == $value) ? 'selected' : ''?> ><?=$arr[0]?> (Width:<?=($arr[1] == 0) ? "auto" : $arr[1] . "px"?>, Height:<?=($arr[2] == 0) ? "auto" : $arr[2] . "px"?>)</option><?
						}
						?>
					</select>
				</td>
			</tr>
			<?
			if($row["adv_type"] == 1){
			?>
				<?=$form->text("URL","adv_link_" . $row["adv_id"],"adv_link_" . $row["adv_id"],$row["adv_link"],"URL",0,250,"",250,"", ' onkeyup="check_edit(\'record_' . $i . '\')" ',"")?>
			<?
			}
			?>
			<?=$form->text("Tiêu đề","adv_title_" . $row["adv_id"],"adv_title_" . $row["adv_id"],$row["adv_title"],"Tiêu đề",0,250,"",250,"", ' onkeyup="check_edit(\'record_' . $i . '\')" ',"")?>
			<?=$form->text("Từ ngày", "adv_startdate_" . $row["adv_id"] . $form->ec . "adv_starttime_" . $row["adv_id"], "adv_startdate_" . $row["adv_id"] . $form->ec . "adv_starttime_" . $row["adv_id"], $adv_startdate . $form->ec . $adv_starttime, "Ngày (dd/mm/yyyy)" . $form->ec . "Giờ (hh:mm:ss)", 0, 100 . $form->ec . 70, $form->ec, 10 . $form->ec . 10, " - ",' onkeyup="check_edit(\'record_' . $i . '\')" ' . $form->ec . ' onkeyup="check_edit(\'record_' . $i . '\')" ', "");?>    
			<?=$form->text("Đến ngày", "adv_enddate_" . $row["adv_id"] . $form->ec . "adv_endtime_" . $row["adv_id"], "adv_enddate_" . $row["adv_id"] . $form->ec . "adv_endtime_" . $row["adv_id"], $adv_enddate . $form->ec . $adv_endtime, "Ngày (dd/mm/yyyy)" . $form->ec . "Giờ (hh:mm:ss)", 0, 100 . $form->ec . 70, $form->ec, 10 . $form->ec . 10, " - ",' onkeyup="check_edit(\'record_' . $i . '\')" ' . $form->ec . ' onkeyup="check_edit(\'record_' . $i . '\')" ', "");?>			
			<?
			$form->close_table();		
			?>
		</td>
		<td align="center"><?=showAdv($row, $fs_filepath, $i)?></td>
		<td align="center" width="60"><input type="text" <?=$list->addAttr($i, "adv_order_"  . $row["adv_id"])?> value="<?=$row["adv_order"]?>" style="width: 50px;" /></td>
		<?=$list->showCheckbox("adv_active", $row["adv_active"], $row["adv_id"])?>
		<?=$list->showCopy($row["adv_id"])?>
		<?=$list->showEdit($row["adv_id"]); ?>
		<?=$list->showDelete($row["adv_id"]); ?>
  		<?=$list->end_tr();?>
	<?
	}
	?>
  <?=$list->showFooter($total_row)?>
</div>
<? /*---------Body------------*/ ?>
</body>
</html>
